package com.tiorb.socketlibrary;

import android.util.Log;

import com.tiorb.socketlibrary.constats.SocketContants;
import com.xuhao.didi.core.iocore.interfaces.IPulseSendable;
import com.xuhao.didi.core.iocore.interfaces.ISendable;
import com.xuhao.didi.core.pojo.OriginalData;
import com.xuhao.didi.socket.client.sdk.client.ConnectionInfo;
import com.xuhao.didi.socket.client.sdk.client.action.SocketActionAdapter;

import java.util.Arrays;

public class SocketAdapter extends SocketActionAdapter {

    @Override
    public void onSocketDisconnection(ConnectionInfo info, String action, Exception e) {
        super.onSocketDisconnection(info, action, e);
        if (e != null) {
            Log.d(SocketContants.TAG, "断开连接 -- 异常断开" + e.toString());
        } else {
            Log.d(SocketContants.TAG, "断开连接 -- 正常断开");
        }
    }

    @Override
    public void onSocketConnectionSuccess(ConnectionInfo info, String action) {
        super.onSocketConnectionSuccess(info, action);
        Log.d(SocketContants.TAG, "连接成功 " + action);
    }

    @Override
    public void onSocketConnectionFailed(ConnectionInfo info, String action, Exception e) {
        super.onSocketConnectionFailed(info, action, e);
        Log.d(SocketContants.TAG, "连接失败" + e.toString());
    }

    @Override
    public void onSocketReadResponse(ConnectionInfo info, String action, OriginalData data) {
        super.onSocketReadResponse(info, action, data);
        Log.d(SocketContants.TAG, "接收数据:" + Arrays.toString(data.getBodyBytes()));
    }

    @Override
    public void onSocketWriteResponse(ConnectionInfo info, String action, ISendable data) {
        super.onSocketWriteResponse(info, action, data);
    }

    @Override
    public void onPulseSend(ConnectionInfo info, IPulseSendable data) {
        super.onPulseSend(info, data);
    }
}
